<?php
class Base_Controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
    }

    protected function success($data=array()){
        $result['code'] = 1;
        $result['data'] = empty($data)?array():$data;
        echo json_encode($result);
        exit;
    }
    protected function error($code=101) {
        switch ($code){
            case 101:
                $msg='params error';
                break;
            case 102:
                $msg='system error';
                break;
            default:
                $msg='unknow error';
        }
        $result ['code'] = $code;
        $result ['errmsg'] = $msg;
        echo json_encode($result);
        exit;
    }
}
